#include "VideoControllerPage.h"
#include "VideoController.h"

VideoControllerPage::VideoControllerPage(const int pageNum) : super(pageNum) {
    mpControllers = &ExtendDeviceManagerSingleton::instance().getExtendDevices(ExtendDeviceEnum::VIDEO_CONTROLLER);
    mpageSize = 1;
}


void VideoControllerPage::paint() {
    std::string content[4];
    resetStream();
    strStream << "videoPlayInfo" << std::right << std::setw(3) << pageNum;// << std::setw(3)
    content[0] = strStream.str();
    if (mpControllers->empty() ) {
        content[1] = ExtendDeviceEnum::NO_DEVICE.name;
    } else {
        ExtendDevicePtr extendDevicePtr = mpControllers->front().lock();
        if (nullptr == extendDevicePtr) {
            content[1] = ExtendDeviceEnum::NO_DEVICE.name;
        } else {
            VideoController* pController = static_cast<VideoController*> (&*extendDevicePtr);
            if (0 == mmultiPageNo) {
                VideoPlayInfo& playInfo = pController->mvideoPlayInfo;
                resetStream();
                strStream << "mode:" << std::setw(2) << std::left << playInfo.mode << " speed:" << std::setw(2) << playInfo.speed;
                content[1] = strStream.str();
                content[2].append("bright:").append(playInfo.bright);
                content[3].append("videoId:").append(playInfo.videoId);

//                std::string videoCount;
//                content[3].append(1, '/').append(pController->getVideoCount(videoCount));
            }
        }
    }

    screen.show(&content[0], &content[1], &content[2], &content[3]);
}

